import React, {useContext} from 'react';
import {UserContext, ThemeContext} from "./context";

const App = () => {
  //使用context
  const user = useContext(UserContext);
  const theme = useContext(ThemeContext);
  //当组件上层最近的<MyContext.Provider>更新时，该Hook会触发重新渲染，
  //并使用最新传递给MyContext.Provider的context value值
  return (
      <div>
        <h2>User: {user.name} - {user.level}</h2>
        <h2 style={{color: theme.color, fontSize: theme.size}}>哈喽</h2>
      </div>
  );
};

export default App;